class TemplateTag < Liquid::Tag
  def initialize(tag_name, template_name, tokens)
    super
    @template_name = template_name
  end

  def render(context)
    template = Template.find_by_name(@template_name.to_s)
    unless template.blank?
      Liquid::Template.parse(template.template).render
    else
      return "Šablona \"#{@template_name}\" nebyla nalezena."
    end
  end

  Liquid::Template.register_tag('get_template', ContentTag)
end
